package com.atomscat.lottery.entity.db;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.OneToMany;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.AbstractAuditable;

import java.io.Serializable;
import java.util.List;
import java.util.Optional;

@Setter
@Getter
@Entity(name = "lottery_activity")
@Schema(description = "Entity representing a lottery activity")
public class LotteryActivityEntity extends Auditable<UserEntity, Long> implements Serializable {

    @Schema(description = "Name of the lottery activity")
    private String name;

    private String picUrl;

    @Schema(description = "Description of the lottery activity")
    private String description;

    /**
     * unpublished,
     * recruiting,
     * active,
     * ended
     */
    @Column(length = 32)
    @Schema(description = "Status of the lottery activity (unpublished, recruiting, active, ended)")
    private String status;

    /**
     * 1. Withdraw after winning,
     * 2. After winning, you can continue to participate in other levels of draws,
     * 3. After winning, you can continue to participate in other levels of draws but the total probability is 50% (customized)
     */
    @Schema(description = "Type of the lottery")
    private String lotteryType;
    /**
     * 0. No limit,
     */
    @Schema(description = "Maximum number of participants")
    private Integer maxParticipants = 0;

    // QR code url
    @Schema(description = "URL of the QR code for the lottery activity")
    private String qrCodeUrl;

    // QR code ticket
    @Schema(description = "URL of the QR code for the lottery activity")
    private String qrCodeTicket;


    @OneToMany(fetch = FetchType.EAGER, mappedBy = "lotteryActivity")
    private List<LotteryPrizeEntity> lotteryPrizes;
}
